package com.znh.kuiklyuniversity.compose.widgets

import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import com.tencent.kuikly.compose.foundation.clickable
import com.tencent.kuikly.compose.foundation.layout.Box
import com.tencent.kuikly.compose.foundation.layout.fillMaxHeight
import com.tencent.kuikly.compose.foundation.layout.height
import com.tencent.kuikly.compose.foundation.layout.padding
import com.tencent.kuikly.compose.foundation.layout.width
import com.tencent.kuikly.compose.foundation.lazy.LazyColumn
import com.tencent.kuikly.compose.foundation.shape.RoundedCornerShape
import com.tencent.kuikly.compose.material3.Text
import com.tencent.kuikly.compose.ui.Alignment
import com.tencent.kuikly.compose.ui.Modifier
import com.tencent.kuikly.compose.ui.draw.clip
import com.tencent.kuikly.compose.ui.graphics.Color
import com.tencent.kuikly.compose.ui.text.font.FontWeight
import com.tencent.kuikly.compose.ui.unit.dp
import com.tencent.kuikly.compose.ui.unit.sp
import com.znh.kuiklyuniversity.backgroundColor
import com.znh.kuiklyuniversity.compose.selfenum.AppColor

@Composable
fun SelectList() {
    var list: List<String> = listOf<String>(
        "a",
        "b",
        "c",
        "d",
        "e",
        "f",
        "g",
        "h",
        "i",
        "j",
        "k",
        "l",
        "m",
        "n",
        "o",
        "p",
        "q",
        "r",
        "s",
        "t",
        "u",
        "v",
        "w",
        "x",
        "y",
        "z"
    )
    var cutSelect: Int by remember { mutableStateOf(-1) }
    LazyColumn(
        modifier = Modifier
            .fillMaxHeight()
            .padding(top = 100.dp, bottom = 100.dp)
            .backgroundColor(Color(125, 125, 125, 75))
            .width(50.dp)
            .clip(RoundedCornerShape(5.dp))
    ) {
        items(list.size) { index ->
            Box(
                modifier = Modifier.height(45.dp)
                    .fillParentMaxWidth().clickable {
                        cutSelect = index
                    },
                contentAlignment = Alignment.Center
            ) {
                Text(
                    list.get(index),
                    color = if (cutSelect == index) {
                        Color.Red
                    } else {
                        AppColor.TxtSelColor.color
                    },
                    fontSize = if (cutSelect == index) {
                        30.sp
                    } else {
                        20.sp
                    },
                    fontWeight = FontWeight.Bold
                )
            }
        }
    }

}